<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>背景切换</title>
<style>
    body {
        background: url(bg_images/b1.jpg) no-repeat center/cover;
    }
    .nav {
        display: flex;
        gap: 12px;
        margin: 100px auto;
        width: 750px;
        padding: 10px;
        background: rgba(0,0,0,0.4);
        border-radius: 8px;
    }
    img {
        width: 150px;
        height: 200px;
        border: 4px solid transparent;
        cursor: pointer;
        transition: border 0.3s, transform 0.3s;
    }
    img:hover {
        border: 4px solid #ffcc00;
        transform: scale(1.08);
    }
</style>
</head>
<body>
    <div class="nav">
        <img src="bg_images/b1.jpg" alt="">
        <img src="bg_images/b2.jpg" alt="">
        <img src="bg_images/b3.jpg" alt="">
        <img src="bg_images/b4.jpg" alt="">
    </div>
<script>
    let imgs = document.querySelectorAll('.nav img');
    for (let img of imgs) {
        img.onclick = function() {
            document.body.style.backgroundImage = `url(${this.src})`;
        };
    }
</script>
</body>
</html>
